package smartbooks.exceptions;

import java.awt.Toolkit;
import javax.swing.JComponent;
import smartbooks.ui.util.MyBalloonTip;

/**
 *
 * @author Ankit
 */
public class MyException extends Exception {
    static MyBalloonTip myBalloonTip = null;
    
    String componentText = new String();
    String balloonTipText = new String();
    
    /**
     * This is a constructor to make BalloonTip
     * @param componentText
     * @param balloonTipText
     */
    public MyException(String componentText, String balloonTipText) {
        this.componentText = componentText;
        this.balloonTipText = balloonTipText;
    }
    
    /**
     * This method will show the Balloontip on the jComponent
     * @param jComponent 
     */
    public void showBalloonTip(JComponent jComponent) {
        hideBalloonTip();
        myBalloonTip = new MyBalloonTip(jComponent, balloonTipText);
        Toolkit.getDefaultToolkit().beep();
    }
    
    /**
     * This method will hide the Balloontip on the jComponent
     */
    public static void hideBalloonTip() {
        if(null!=myBalloonTip) {
            myBalloonTip.setVisible(false);
        }
    }
    
    /**
     * This method will get the Component text which will determine which Component should show the Balloontip
     * @return component text
     */
    public String getComponentText() {
        return componentText;
    }
    
    /**
     * This method will get the BalloonTip text which will determine the Balloontip on the Component
     * @return balloonTipText
     */
    public String getBalloonTipText() {
        return balloonTipText;
    }
}